void setFileName(void) {
  // Forms Sequential File Names, storing sequence number in EEPROM
  unsigned int fileNum = (int(EEPROM.read(FILE_NUM_EE+1)) << 8) + EEPROM.read(FILE_NUM_EE);
  
  fileName = "Log" + String(fileNum) + ".txt";
  
  EEPROM.write(1, byte((++fileNum >> 8) & 0xFF));
  EEPROM.write(0, byte(fileNum & 0xFF));
}

void SDopenFile(void) {
  if (haveSD && !fileOpen) {
    setFileName();
    char fname[13];
    unsigned int len = fileName.length();
    fileName.toCharArray(fname, len + 1);
    logFile = SD.open(fname, FILE_WRITE);
    if (logFile) {
      timeTagged = false;
      fileOpen = true;
    } else {
      fileOpen = false;
    }
  }
}

void SDcloseFile(void) {
  if (fileOpen) {
    logFile.close();
    fileOpen = false;
  }
}
